package com.zhixi100.gatewayservice.filter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

@Service
public class RedisService {

    @Autowired
    private RedisTemplate redisTemplate;

    public void test() {
        redisTemplate.opsForValue().set("tommy", "123456");

        Object str = redisTemplate.opsForValue().get("tommy");
        System.out.println(str);

        Map map = new HashMap();
        map.put("1", "a");
        map.put("2", "b");
        redisTemplate.opsForValue().set("map", map, 30, TimeUnit.MINUTES);

        Map obj = (Map)redisTemplate.opsForValue().get("map");
        System.out.println(obj);
    }
}
